package com.woniu.p2p.behindServiceImpl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniu.p2p.behindService.MyBorrowService;
import com.woniu.p2p.entity.User;
import com.woniu.p2p.entity.UserLoans;
import com.woniu.p2p.mapper.UserLoansMapper;
import com.woniu.p2p.mapper.UserMapper;
import com.woniu.p2p.vo.BorrowVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class MyBorrowServiceImpl implements MyBorrowService {

    @Autowired
    UserLoansMapper userLoansMapper;
    @Autowired
    UserMapper userMapper;

    @Override
    public PageInfo<BorrowVo> findAllBorrow(Integer start, Integer num, String borrowstatus, Date predate, Date nextdate, String borrowkeyword) {
        PageHelper.startPage(start,num);
        List<BorrowVo> list = userLoansMapper.findAllBorrow(borrowstatus, borrowkeyword, predate, nextdate);
        PageInfo<BorrowVo> pageInfo=new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public UserLoans findAllUserLoansByLoansId(Integer id) {
        return userLoansMapper.findAllUserLoansByLoansId(id);
    }

    @Override
    public User findAllUserById(Integer id) {
        return userMapper.selectByPrimaryKey(id);
    }

    @Override
    public int deleteBorrowById(Integer id) {
        return userLoansMapper.deleteByPrimaryKey(id);
    }

    @Override
    public List<BorrowVo> findAllBorrow(int[] id) {
        return userLoansMapper.findAllBorrowsByIdes(id);
    }


}
